﻿using System;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Configuration;
using System.Diagnostics;
using System.ServiceModel.Diagnostics;

namespace IAOI.Platform.WCF.WCF.Dispatch
{
    public class ServiceDispatch : BehaviorExtensionElement//, IServiceBehavior// IEndpointBehavior
    {
        public override Type BehaviorType
        {
            get { return typeof(ServiceBehavior); }
        }

        protected override object CreateBehavior()
        {
            ServiceBehavior sb = new ServiceBehavior();

            sb.ServiceDispatch = this;
            //sb.IsMessageLog = IsMessageLoging;
            //sb.IsParameterLog = IsParameterLoging;
            //sb.IsErrorHandler = IsErrorHandler;
            return sb;
        }

        [ConfigurationProperty("parameterLoging", IsRequired = true, DefaultValue = false)]
        public bool IsParameterLoging
        {
            get
            {
                return (bool)base["parameterLoging"];
            }
            set
            {
                base["parameterLoging"] = value;
            }
        }


        [ConfigurationProperty("messageLoging", IsRequired = false, DefaultValue = false)]
        public bool IsMessageLoging
        {
            get
            {
                return (bool)base["messageLoging"];
            }
            set
            {
                base["messageLoging"] = value;
            }
        }

        [ConfigurationProperty("errorHandler", IsRequired = false, DefaultValue = false)]
        public bool IsErrorHandler
        {
            get
            {

                return (bool)base["errorHandler"];
            }
            set
            {
                base["errorHandler"] = value;
            }
        }


        [ConfigurationProperty("TraceLevel", IsRequired = true, DefaultValue = false)]
        public TraceLevel TraceLevel
        {
            get
            {
                return (TraceLevel)base["TraceLevel"];
            }
            set
            {

                base["TraceLevel"] = value;
            }
        }




        [ConfigurationProperty("performanceCounterScope", IsRequired = true, DefaultValue = PerformanceCounterScope.Default)]
        public PerformanceCounterScope performanceCounterScope
        {
            get
            {
                return (PerformanceCounterScope)base["performanceCounterScope"];
            }
            set
            {
                base["performanceCounterScope"] = value;
            }
        }

        [ConfigurationProperty("tracingLevel", IsRequired = true, DefaultValue = SourceLevels.Off)]
        public SourceLevels tracingLevel
        {
            get
            {
                return (SourceLevels)base["tracingLevel"];
            }
            set
            {
                base["tracingLevel"] = value;
            }
        }

        [ConfigurationProperty("messageLoggingLevel", IsRequired = true, DefaultValue = PerformanceCounterScope.Default)]
        public SourceLevels messageLoggingLevel
        {
            get
            {
                return (SourceLevels)base["messageLoggingLevel"];
            }
            set
            {
                base["messageLoggingLevel"] = value;
            }
        }

        [ConfigurationProperty("maxSizeOfMessageToLog", IsRequired = true, DefaultValue = 262144)]
        public int maxSizeOfMessageToLog
        {
            get
            {
                return (int)base["maxSizeOfMessageToLog"];
            }
            set
            {
                base["maxSizeOfMessageToLog"] = value;
            }
        }


        [ConfigurationProperty("connectionStringName", IsRequired = true, DefaultValue="LOGDB")]
        public string connectionStringName
        {
            get
            {
                return (string)base["connectionStringName"];
            }
            set
            {
                base["connectionStringName"] = value;
            }
        }



    }
}
